#define __DEBUG__
// by Xeno
#define THIS_FILE "fn_checkmthardtarget.sqf"
#include "x_setup.sqf"

private ["_vehicle", "_trigger", "_trigger2"];
PARAMS_1(_vehicle);
[_vehicle] execFSM "fsms\XRemoveVehiExtra.fsm";
_vehicle addEventHandler ["killed", {
	GVAR(mt_spotted) = false;
	if (GVAR(IS_HC_CLIENT)) then {
		[QGVAR(sSetVar), [QGVAR(mt_spotted), false]] call FUNC(NetCallEventCTS);
	};
	[QGVAR(mt_radio_down),true] call FUNC(NetSetJIP);
	deleteMarker QGVAR(main_target_radiotower);
	#ifndef __TT__
	[QGVAR(kbmsg), [37]] call FUNC(NetCallEventCTS);
	#else
	[QGVAR(kbmsg), [38]] call FUNC(NetCallEventCTS);
	[GVAR(tt_points) select 2,_this select 1] call FUNC(AddPoints);
	_killedby = switch (_this select 1) do {case blufor: {"US"};case opfor: {"OPFOR"};default {"N"};};
	if (_killedby != "N") then {
		[QGVAR(kbmsg), [39, _killedby]] call FUNC(NetCallEventCTS);
	};
	#endif
	__TRACE_1("Radio Down","_this")
}];
if (GVAR(domdatabase)) then {
	_vehicle addMPEventHandler ["MPKilled", {if (isServer && {isPlayer (_this select 1)}) then {(_this select 1) call FUNC(PAddRadioTowerKillPoints);(_this select 0) removeAllMPEventHandlers "MPKilled"}}];
};
_vehicle addEventHandler ["handleDamage", {_this call FUNC(CheckMTShotHD)}];